package rickyGame.game.graphic
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.geom.Rectangle;
	
	import ricky.game.graphic.Graphic;
	
	import rickyGame.game.Fighter;
	import rickyGame.game.property.property.AgileValue;
	
	/**
	 * 战斗图形
	 */
	public class FightGraphic extends Graphic
	{
		public function FightGraphic(character:Fighter=null)
		{
			super(character);
			_fightObj=character;
		}
		
		/**
		 * 显示血条
		 */
		public function showBloodBar():void
		{
			if(!_bmp)
			{
				_bmp=new Bitmap(new BitmapData(80,40,true,0));
				_bmp.x=-30;
				_bmp.y=20;
				var ind:int=0;
				if(_clothes)
					ind=this.getChildIndex(this._clothes);
				this.addChildAt(_bmp,ind+1);
			}
			
			hp(_fightObj.fightPro.hp);
			mp(_fightObj.fightPro.mp);
		}
		
		/**
		 * 绑定属性血条
		 *  @param agile:AgileValue角色对应的生命值
		 */
		private function hp(agile:AgileValue):void
		{
			_bmp.bitmapData.fillRect(new Rectangle(0,5,40,4),0xffffff00);//背景血条
			_bmp.bitmapData.fillRect(new Rectangle(0,5,(agile.agileValue/agile.value*40),4),0xffff0000);//血条
		}
		
		private function mp(agile:AgileValue):void
		{
			_bmp.bitmapData.fillRect(new Rectangle(0,0,40,4),0xffffff00);//背景蓝条
			_bmp.bitmapData.fillRect(new Rectangle(0,0,(agile.agileValue/agile.value*40),4),0xff00ffff);//背景蓝条
		}
		
		private var _fightObj:Fighter;//玩家
		
		private var _bmp:Bitmap;
	}
}